
#pragma once

#include <stdlib.h>

//If it is defined, some additional checks will be performed (e.g. division by zero, recieving NULL, etc).
//Otherwise, it can crash.
#define TTG_DEBUG

namespace ttgLib
{
//Current versions of nvcc cannot understand some template functions.
#ifndef __CUDACC__

	//Deletes required object.
	template <class T>
	void SAFE_DELETE(T *&object)
	{
		if (object != NULL)
		{
			delete object;
			object = NULL;
		}
	}

	//Deletes required array of objects.
	template <class T>
	void SAFE_DELETE_ARRAY(T *&arr)
	{
		if (arr != NULL)
		{
			delete[] arr;
			arr = NULL;
		}
	}

	//Deletes all content all stl-container (such as std::vector or std::list).
	template <class Container>
	inline void SAFE_DELETE_CONTENT(Container *container)
	{
		if (container != NULL)
		{
			Container::iterator it = container->begin();
			while (it != container->end())
			{
				if (*it != NULL)
					delete *it;
				it++;
			}
			container->clear();
		}
	}

#endif //nvcc-check

	//Contains information about version of the ttgLib.
	class Version
	{
		public:
			//Major number of the version (e.g. 0, 1, etc).
			static const int Major;
			//Minor number of the version (e.g. 01, 02, 10, etc).
			static const int Minor;
			//Suffex of the version (e.g. a1, pa1, b2).
			static const char * const Suffix;
			//Returns fromatted version (e.g. "0.01-pa4").
			static const char *ToString();
	};
}
